package com.eshop.common.web.param;

import java.util.Collection;
import cn.hutool.core.collection.CollectionUtil;
import java.util.Arrays;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import java.util.List;
import io.swagger.annotations.ApiModel;

@ApiModel("可排序查询参数对象")
public abstract class OrderQueryParam extends QueryParam
{
    private static final long serialVersionUID = 57714391204790143L;
    @ApiModelProperty("排序")
    private List<OrderItem> orders;
    
    public void defaultOrder(final OrderItem orderItem) {
        this.defaultOrders(Arrays.asList(orderItem));
    }
    
    public void defaultOrders(final List<OrderItem> orderItems) {
        if (CollectionUtil.isEmpty(orderItems)) {
            return;
        }
        this.orders = orderItems;
    }
    
    public List<OrderItem> getOrders() {
        return this.orders;
    }
    
    public void setOrders(final List<OrderItem> orders) {
        this.orders = orders;
    }
    
    @Override
    public String toString() {
        return "OrderQueryParam(orders=" + this.getOrders() + ")";
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof OrderQueryParam)) {
            return false;
        }
        final OrderQueryParam other = (OrderQueryParam)o;
        if (!other.canEqual(this)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        final Object this$orders = this.getOrders();
        final Object other$orders = other.getOrders();
        if (this$orders == null) {
            if (other$orders == null) {
                return true;
            }
        }
        else if (this$orders.equals(other$orders)) {
            return true;
        }
        return false;
    }
    
    @Override
    protected boolean canEqual(final Object other) {
        return other instanceof OrderQueryParam;
    }
    
    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = super.hashCode();
        final Object $orders = this.getOrders();
        result = result * 59 + (($orders == null) ? 43 : $orders.hashCode());
        return result;
    }
}
